<script lang="ts" name="transferOrder" setup>
import { ref, reactive, onMounted } from "vue";
import { ElMessage } from "element-plus";
import type { FormRules } from "element-plus";
import { useTransferOrderApi } from '/@/api/main/transferOrder';

//父级传递来的函数，用于回调
const emit = defineEmits(["reloadTable"]);
const transferOrderApi = useTransferOrderApi();
const ruleFormRef = ref();

const state = reactive({
    title: '',
    loading: false,
    showDialog: false,
    ruleForm: {} as any,
    stores: {},
    dropdownData: {} as any,
});

// 自行添加其他规则
const rules = ref<FormRules>({
});

// 页面加载时
onMounted(async () => {
});

// 打开弹窗
const openDialog = async (row: any, title: string) => {
    state.title = title;
    row = row ?? {};
    state.ruleForm = row.id ? await transferOrderApi.detail(row.id).then(res => res.data.result) : JSON.parse(JSON.stringify(row));
    state.showDialog = true;
};

//将属性或者函数暴露给父组件
defineExpose({ openDialog });
</script>
<template>
    <div class="transferOrder-container">
        <el-dialog v-model="state.showDialog" :width="800" draggable :close-on-click-modal="false">
            <template #header>
                <div style="color: #fff">
                    <span>{{ state.title }}</span>
                </div>
            </template>
            <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
                <el-row :gutter="35">
                    <el-form-item v-show="false">
                        <el-input v-model="state.ruleForm.id" />
                    </el-form-item>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="ICCID">
                            <el-input type="textarea" rows="10" v-model="state.ruleForm.codeRange" clearable readonly />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="() => state.showDialog = false">确 定</el-button>
                    <!-- <el-button @click="submit" type="primary" v-reclick="1000">确 定</el-button> -->
                </span>
            </template>
        </el-dialog>
    </div>
</template>
<style lang="scss" scoped>
:deep(.el-select),
:deep(.el-input-number) {
    width: 100%;
}
</style>